package com.example.artwindow.controller;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.artwindow.domain.dto.AdUploadDTO;
import com.example.artwindow.domain.po.Ad;
import com.example.artwindow.result.Result;
import com.example.artwindow.service.AdService;
import com.example.artwindow.tool.CopyProperties;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.jdbc.Null;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("recruit")
@Tag(name = "招募相关接口")
@Slf4j
@RequiredArgsConstructor
public class RecruitController {

	private final AdService adService;

	@PostMapping()
	@Operation(summary = "招募上传接口")
	private Result<Null> uploadRecruit(@RequestBody AdUploadDTO adUploadDTO){
		Ad ad = BeanUtil.copyProperties(adUploadDTO, Ad.class);
		ad.setRecruit(1);
		return adService.AdUploadDTO(ad);
	}

	@GetMapping("招募查看接口")
	private Result<List<Ad>> listRecruit(){

		return adService.listRecruit();
	}
}
